/**
 * Copyright (c) 2018 软唐 All rights reserved.
 *
 * https://www.softtown.cn
 *
 * 版权所有，侵权必究！
 */

package com.softtown.modules.dapai.controller;

import com.github.pagehelper.PageInfo;
import com.softtown.common.utils.Result;
import com.softtown.modules.dapai.dto.CompMacTypeDTO;
import com.softtown.modules.dapai.entity.CompMacTypeEntity;
import com.softtown.modules.dapai.service.CompMacTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
* @Author: Ding Ya Yong
* @Description: 设备分类
* @date: 2022/1/2 20:47
* @Param:
* @return:
*/
@RestController
@RequestMapping("macType")
@Api(tags="设备分类")
public class CompMacTypeController {

    @Resource
    private CompMacTypeService compMacTypeService;

    @PostMapping("getMacTypePageList")
    @ApiOperation("获取设备分类分页")
    public Result getMacTypePageList(@RequestBody CompMacTypeDTO compMacTypeDTO) {
        PageInfo<CompMacTypeDTO> compMacTypeDTOPageInfo = compMacTypeService.getMacTypePageList(compMacTypeDTO);
        return new Result<PageInfo<CompMacTypeDTO>>().ok(compMacTypeDTOPageInfo);
    }



    @PostMapping("getMacTypeById")
    @ApiOperation("获取设备分类详情")
    public Result<CompMacTypeEntity> getMacTypeById(@RequestBody CompMacTypeDTO compMacTypeDTO) {
        CompMacTypeEntity compMacTypeEntity = compMacTypeService.getMacTypeById(compMacTypeDTO.getCompId(),compMacTypeDTO.getId());
        return new Result<CompMacTypeEntity>().ok(compMacTypeEntity);
    }


    @PostMapping("addMacType")
    @ApiOperation("添加设备分类")
    public Result addMacType(@RequestBody CompMacTypeDTO compMacTypeDTO) {
        Result result = new Result<>();
        compMacTypeService.addMacType(compMacTypeDTO);
        return result;
    }

    @PostMapping("updateMacType")
    @ApiOperation("修改设备分类")
    public Result updateMacType(@RequestBody CompMacTypeDTO compMacTypeDTO) {
        Result result = new Result<>();
        compMacTypeService.updateMacType(compMacTypeDTO);
        return result;
    }

    @PostMapping("deleteMacType")
    @ApiOperation("删除设备分类")
    public Result deleteMacType(@RequestBody CompMacTypeDTO compMacTypeDTO) {
        Result result = new Result<>();
        compMacTypeService.deleteMacType(compMacTypeDTO);
        return result;
    }

    @PostMapping("listForMacType")
    @ApiOperation("设备分类下拉框")
    public Result listForMacType(@RequestBody CompMacTypeDTO compMacTypeDTO) {
        List<CompMacTypeDTO> compMacTypeDTOList = compMacTypeService.listForMacType(compMacTypeDTO);
        return new Result<List<CompMacTypeDTO>>().ok(compMacTypeDTOList);
    }

}
